


#include <iostream>
#include <boost/array.hpp>
#include <boost/asio.hpp>

using boost::asio::ip::tcp;
using namespace boost::asio::ip;

namespace daytime1_client{

int main()
{
	try
	{
		boost::asio::io_service io_service;

		tcp::endpoint ep(boost::asio::ip::address::from_string("127.0.0.1") , 13) ;

		tcp::socket socket(io_service);
		//boost::asio::connect(socket, &ep);
		socket.connect(ep);

		for (;;)
		{
			boost::array<char, 128> buf;
			boost::system::error_code error;

			size_t len = socket.read_some(boost::asio::buffer(buf), error);

			if (error == boost::asio::error::eof)
				break; // Connection closed cleanly by peer.
			else if (error)
				throw boost::system::system_error(error); // Some other error.

			std::cout.write(buf.data(), len);
		}
	}
	catch (std::exception& e)
	{
		std::cerr << e.what() << std::endl;
	}

	return 0;
}

}